package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"patient/models"
)

type PatientController struct {
	beego.Controller
}

func (c *PatientController) List() {
	c.Ctx.Output.Header("Access-Control-Allow-Origin", "*")

	var patient []models.Patient
	err := models.DB.Find(&patient).Error

	if err != nil {
		c.Data["json"] = map[string]interface{}{
			"code":    500,
			"message": "挂号列表展示失败",
		}
		c.ServeJSON()
		return
	}

	c.Data["json"] = map[string]interface{}{
		"code":    200,
		"message": "挂号列表展示成功",
		"data":    patient,
	}
	c.ServeJSON()
}
